class ShaiZi extends eui.Component {
	public f_image: eui.Image;
	public f_action: how.Animation;
	public s_image: eui.Image;
	public s_action: how.Animation;

	private sourceArray = [1, 3, 6, 10, 14, 18];
	public constructor() {
		super();
		this.skinName = "ShaiziSkin";
	}

	public childrenCreated(): void {
		this.visible = false;
	}
	public to(d: Array<number>, cb?: Function, thisObject?: any): void {
		how.SoundManager.playSound("shaizi_mp3");
		let f_ok = false;
		let s_ok = false;
		let self = this;
		this.visible = true;
		this.f_action.play();
		this.s_action.play();
		egret.setTimeout(() => {
			this.f_action.visible = false
			this.f_action.stop();
			this.f_image.source = "shaizi_" + this.sourceArray[d[0] - 1] + "_png";
			this.f_image.visible = true;
			f_ok = true;
			isOK();
		}, this, 1000);
		egret.setTimeout(() => {
			this.s_action.visible = false
			this.s_action.stop();
			this.s_image.source = "shaizi_" + this.sourceArray[d[1] - 1] + "_png";
			this.s_image.visible = true;
			s_ok = true;
			isOK();
		}, this, 1500);
		let isOK = function () {
			if (f_ok && s_ok) {
				self.scaleX = self.scaleY = 2.0;
				egret.setTimeout(() => {
					self.visible = self.f_image.visible = self.s_image.visible = false;
					self.f_action.visible = self.s_action.visible = true;
					self.scaleX = self.scaleY = 1.0;
					if (cb) {
						cb.apply(thisObject);
					}
				}, self, 2000)
			}
		}
	}
}
